<%@page import="Model.GioHang"%>
<%@page import="javax.swing.ListModel"%>
<%@page import="Model.Mobile"%>
<%@page import="Model.LineMobile"%>
<%@page import="java.util.ArrayList"%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%// Cart cart = (Cart) session.getAttribute("cart");
GioHang cart = (GioHang) session.getAttribute("cart");
//ArrayList<LineMobile> listLineMb = null;
ArrayList<Mobile> listLineMb = null;

if(cart!=null){
           listLineMb  = cart.getGioHang();
}
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="SHORTCUT ICON" href="image/shrotcuticon.png"></link>
        <title>Mobile Shop</title>

        <link href="css/style.css" rel="stylesheet" type="text/css" />
        <link rel="stylesheet" type="text/css" href="menu/menu_style.css" />
        <link rel="stylesheet" href="slide/nivo-slider.css" type="text/css" media="screen" />
        <link rel="stylesheet" href="slide/style.css" type="text/css"/>
        <script type="text/javascript" src="slide/scripts/jquery-1.4.3.min.js"></script>
        <script type="text/javascript" src="slide/jquery.nivo.slider.pack.js"></script>
        <script type="text/javascript" src="menu/stmenu.js"></script>

        <script type="text/javascript">
            $(window).load(function() {
                $('#slider').nivoSlider();
            });
        </script>
        <script type="text/javascript" src="tooltip/jtip.js"></script>
        <link href="tooltip/css/global.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="validate.js"></script>
        <script type="text/javascript">
            function validate(){
                return confirm("Bạn có thật sự muốn xóa loại điện thoại này khỏi giỏ hàng");
            }
        </script>

    </head>

    <body>
        <a name="top" id="top"></a>
        <div id="frame">
            <div id="page">
                <div id="header">
                    <%@include file="header.jsp"  %>
                    <%@include file="menu.jsp" %>

                </div>
                <!--        end header -->
                    <div id="content">
                    <%@include file="leftpane.jsp" %>
                    <div id="rightside">

                        <%@include file="slide.jsp" %>
                        <div></div>
                        <%if(listLineMb!=null){%>
                        <div id="cart" style="margin-left:5px;margin-top:50px;">
                            <div class="box_header">
                                <h4 class="title_center">GIỎ HÀNG CỦA BẠN</h4>
                            </div >
                            <div class="box_center">
                                
                                <table width="100%" border="0" cellspacing="0" cellpadding="5">
                                    <tr bgcolor="#A1C8EF">
                                        <th align="center" scope="col">ẢNH	</th>
                                        <th align="center" scope="col">SẢN PHẨM</th>
                                        <th align="center" scope="col">GIÁ</th>
                                        <th align="center" scope="col">SỐ LƯỢNG</th>
                                        <th align="center" scope="col">THÀNH TIỀN</th>
                                        <th align="center" scope="col">&nbsp;</th>
                                    </tr>
                                    <%for (Mobile lineMb : listLineMb) {
                                        Mobile mb = lineMb;%>
                                    <tr>
                                        <td align="center" valign="middle"><img src="<%=mb.getAnhDaiDien()%>" width="59" height="88" /></td>
                                        <td align="center" ><a href="index.jsp?mobileID=<%=mb.getMobileID()%>"><%=mb.getTenSP()%></a></td>
                                        <td align="center" width="20%"><span class="style1"><%=mb.formatedDiscount()%> VND</span></td>
                                        <td align="center">
                                            <form id="form1" name="form1" method="get" action="Order">
                                                <input type="hidden" name="mobileID" value="<%=mb.getMobileID()%>" />
                                                <input type="text" name="quantity" id="quantity" value="<%=lineMb.getSoLuong()%>" />
                                                <input  type="submit" value="Cập nhật" />
                                                <input type="hidden" name="action" value="update">
                                            </form>
                                        </td>
                                        <td align="center"><span class="style1"><%=lineMb.getTotalCurrencyFormat()%> VND</span></td>
                                        <td align="center">
                                            <form id="form2" name="form2" method="get" action="Order">
                                                <input type="hidden" name="mobileID"  value="<%=mb.getMobileID()%>"/>
                                                <input name="quantity" type="hidden" value="0"/>
                                                <input type="submit" value="Xóa khỏi giỏ hàng" onclick="return validate()"/>
                                            </form>
                                        </td>
                                    </tr>
                                    <%}%>
                                    <tr>
                                        <td colspan="4">&nbsp;</td>
                                        <td>Tổng số: <span class="style1"><%=cart.getTotal()%> VND</span></td>
                                        <td></td>
                                    </tr>
                                   
                                    <tr align="center">

                                        <td colspan="6">
                                            <input  onclick="window.location='index.jsp'" type="button" value="Tiếp tục mua hàng" />
                                            <input onclick="window.location='Pay'" type="button" value="Thanh toán"/>

                                        </td>

                                    </tr>
                                     
                                </table>
                            </div>
                        </div>
                                        <%}
                                        else{
%><h3 style="color: blue;text-align: center;padding: 40px 5px;">Hiện giỏ hàng của bạn chưa có mặt hàng nào. Vui lòng click vào <a href="index.jsp">đây</a> để tiếp tục mua hàng.</h3>
<%}%>
                    </div>
                </div>
                <!--    end content -->

                <!--    end content -->
            </div>
            <%@include file="footer.jsp" %>
            <!--    end page -->
        </div>
    </body>
</html>
